package MetaApp;

import java.util.*;

public class One {


    public static void main(String[] args) {
        int[] arr = new int[]{6,2,3,1};
        System.out.println(answer(arr));
    }
    /**
     * 请勿修改返回值类型
     */
    public static int answer(int[] x) {
        int one = getOne(x);
        int[] two = getTwo(one);
        int three = getThree(two);
        return three;
    }

    public static int getOne(int[] x) {
        Set<Integer> set = new HashSet<>();
        for(int n : x) {
            set.add(n);
        }
        return set.size();
    }
    public static int[] getTwo(int n) {
        List<Integer> list = new ArrayList<>();
        n = n<0 ? -n : n;
        for(int i=1; i<=n; i++) {
            if(n%i==0) {
                list.add(i);
            }
        }
        int[] array = new int[list.size()];
        for (int i=0; i<list.size(); i++) {
            array[i] = list.get(i);
        }
        Arrays.sort(array);
        if (list.size() <= 9) {
            return array;
        } else {
            int[] result = new int[9];
            int index = 0;
            for(int i=array.length-1; i>=0; i--) {
                result[index++] = array[i];
            }
            return result;
        }
    }
    private static int getThree(int[] array) {
        List<Integer> list = new ArrayList<>();
        for (int i : array) {
            list.add(i);
        }
        while (list.size() > 4) {
            List<Integer> newList = new ArrayList<>();
            for (int i = 0; i < list.size(); i++) {
                if ((i+1)%5 != 0) {
                    newList.add(list.get(i));
                }
            }
            list = newList.subList(0, newList.size());
        }
        return list.get(list.size()-1);
    }

}
